import { createStore } from 'vuex'
import cart from './modules/cart'
import user from './modules/user'
import category from './modules/category'
import createPersistedState from "vuex-persistedstate"

export default createStore({
  state: {
    username: '张三' 
  },
  getters: {
  },
  mutations: {
  },
  actions: {
  },
  modules: {
    cart,
    user,
    category
  },
  plugins: [
    // 默认存储在localStorage中
    createPersistedState({
          //  本地缓存的名字
          key: 'erabbit-client-pc-store',
          // 指定需要缓存的模块
          paths: ['user', 'cart']
        })
      ]
})
